﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PersonProperty
{
    class Person
    {
        private string firstName;
        private string lastName;
        private string gender;
        private byte age;
        public event  PropertyChangedEventHandler PropertyChanged;

        public Person(string firstName, string lastName, string gender, byte age)
        {
            this.firstName = firstName;
            this.lastName = lastName;
            this.gender = gender;
            this.age = age;
        }

        protected void OnPropertyChanged(string property,string changedProperty,string changedToProperty)
        {
            if (PropertyChanged != null)
            {
                PropertyChangedEventArgs args = new PropertyChangedEventArgs(property, changedProperty, changedToProperty);
                PropertyChanged(this, args);
                Console.WriteLine("{0} changes. {1} is changed to {2}.",property, changedProperty, changedToProperty);
            }
        }
        public string FirstName
        {
            get
            {
                return firstName;
            }
            set
            {
                OnPropertyChanged("firstName",firstName,value);
                firstName = value;
               
            }
        }

        public string LastName
        {
            get
            {
                return lastName;
            }
            set
            {
                OnPropertyChanged("lastName",lastName, value);
                lastName = value;
            }
        }

        public string Gender
        {
            get
            {
                return gender;
            }
            set
            {
                OnPropertyChanged("gender",gender, value);
                gender = value;
            }
        }

        public byte Age
        {
            get
            {
                return age;
            }
            set
            {
                OnPropertyChanged("age",age.ToString(), value.ToString());
                age = value;
            }
        }
    }
}
